<%@page import="java.io.OutputStream"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@page import="edu.kit.los.servlets.Servlet"%>
<%@page import="java.net.URL"%>
<%@page import="java.util.Map"%>
<%	response.setContentType(Servlet.contentType_HTML);
	String[] sourceArray = request.getParameterValues("source");
	String source = "";
	if(sourceArray!=null && sourceArray.length!=0){
		for (String s : sourceArray){
			source += "&source="+s;
		}
	}
	else source = "";
	Map<String, String> param = Servlet.parameters(request);
	URL url = new URL("http://kit-services.appspot.com/event?format=kml&query="
	+ param.get("query") + "&limit=" + param.get("limit") 
	+ source);
%>
<!DOCTYPE html>
<html>
	<head>
		<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
		<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
		<title>Event Search</title>
		<link href="/stylesheets/map.css" rel="stylesheet" type="text/css" />
		<script type="text/javascript" src="//maps.googleapis.com/maps/api/js?sensor=false"></script>
		<script type="text/javascript">
			function initialize() {
				var myOptions = {
					zoom : 2,
					center : new google.maps.LatLng(0,0),
					mapTypeId : google.maps.MapTypeId.ROADMAP
				}				
				var ctaLayer = new google.maps.KmlLayer("<%=url%>");
				ctaLayer.setMap(new google.maps.Map(document.getElementById('map_canvas'), myOptions));			
			}
		</script>
	</head>
	<body onload="initialize()">
		<div id="map_canvas"></div>
	</body>
</html>